# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>

pkgname=unicode-character-database
pkgver=14.0.0
pkgrel=1
pkgdesc="Unicode Character Database"
url="https://www.unicode.org/"
arch=(any)
license=(BSD)
makedepends=(lynx)
source=("UCD-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/UCD.zip"
        "Unihan-$pkgver.zip::https://www.unicode.org/Public/zipped/$pkgver/Unihan.zip"
        "unicode-license.html::https://www.unicode.org/license.html")
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('17fbfb3ebd3a75227526d87e19feb70c1b0ccee656e421e955aadc88847ed2597437eb8cf19619e2a49470d286b285e219aec18d6b29dab47cfa8317a212b458'
            '1827e512dd1bd27f3553746275dc90e3c3add38590d56da3901eccb56b94fee9e2dd806514a866ca73dfe4770ec585d200a6b6a7a4293c2ff572a2f5b50ef091'
            '91ed5783a76e109af7ec9229f15d266edb812f238c671223f9455cd4a591d0c5079cfaeff610c20b05f1ae59a2a3514e021d55c0f35184a18fa7f6b5a7acf4a8')

build() {
  lynx -dump -display_charset=utf-8 unicode-license.html > LICENSE
}

package() {
  for _f in UCD Unihan; do
    install -Dm644 $_f-$pkgver.zip "$pkgdir/usr/share/unicode/$_f.zip"
    bsdtar -C "$pkgdir/usr/share/unicode" -x --no-same-owner --no-same-permissions -f $_f-$pkgver.zip
  done

  # FS#49938: A bunch of compatibility symlinks
  ln -s . "$pkgdir/usr/share/unicode/ucd"
  for _f in $pkgname unicode-data unidata; do
    ln -s unicode "$pkgdir/usr/share/$_f"
  done

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 LICENSE
}
